package com.study.langchain4j.api;

import com.study.langchain4j.service.BaseHighLevelHelloWorldChatService;
import dev.langchain4j.model.chat.response.ChatResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xl-9527
 * @since 2025/10/27
 **/
@RestController
@RequestMapping("ai/chat/base/high-level")
public class BaseHighLevelHelloWorldChatApi {

    private final BaseHighLevelHelloWorldChatService baseHighLevelHelloWorldChatService;

    public BaseHighLevelHelloWorldChatApi(final BaseHighLevelHelloWorldChatService baseHighLevelHelloWorldChatService) {
        this.baseHighLevelHelloWorldChatService = baseHighLevelHelloWorldChatService;
    }

    @GetMapping("/hello")
    public String hello(@RequestParam("userMessage") String userMessage) {
        final ChatResponse chatResponse = baseHighLevelHelloWorldChatService.hello(
                userMessage
        );
        return chatResponse.aiMessage().text();
    }
}
